package com.seari.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.seari.bean.DataGridBean;
import com.seari.entity.EtDispose;
import com.seari.entity.EtInformation;
import com.seari.entity.EtMaintainRecord;
import com.seari.entity.EtPatrolPlan;
import com.seari.service.EquipmentService;

@Controller
@RequestMapping(value = "/ec")
public class EquipmentController extends BaseController{
	
	
	@Autowired
	private EquipmentService equipmentService;
	
	
	@GetMapping("/")
	public String fault(Model model) {
		return "/fault";
	}
	

	@ResponseBody
	@RequestMapping(value = "/getEquipmentMsg")
	public DataGridBean<Object> getDomainGraph(String etCode,String faultContent) {
	
		DataGridBean<Object> grid = new DataGridBean<>();
		
		Map<Object, Object> dataMap = new HashMap<Object,Object>();
		
		// 获取设备厂商信息
		List<EtInformation> etInformations = equipmentService.getEtInformation(etCode);
		dataMap.put("etInformations",etInformations);
		// 获取设备维修历史数据
		List<EtMaintainRecord>etMaintainRecords = equipmentService.getEtMaintainRecordMsg(etCode);
		dataMap.put("etMaintainRecords",etMaintainRecords);
		// 获取同类故障处置方式
		List<EtDispose>deviceDispose = equipmentService.getDeviceDispose(etCode,faultContent);
		dataMap.put("deviceDispose",deviceDispose);
		// 获取巡检计划
		List<EtPatrolPlan>etPatrolPlans= equipmentService.getEtPatrolPlan(etCode);
		dataMap.put("etPatrolPlans",etPatrolPlans);
		
		grid.setData(dataMap);
		
		return grid;
	}
	
	
	
	
	
	
	

}
